<?php

class Application_Form_Updateprofile extends Zend_Form {

    public function __construct() {
        //$translate = new My_Action_Helper_Lang();

        $this->setName('validate');
        $this->setAttrib('class', 'form');
        parent::__construct();

        $login = new Zend_Form_Element_Text('login');
        $login->setLabel('Username')
                ->addValidator('NotEmpty')
                ->addValidator('Db_NoRecordExists', false, array(
                    'table' => 'publishers',
                    'field' => 'login'))
                ->addFilter('StringTrim')
                ->addFilter('StripTags')
                ->setAttrib('id', 'login')
                ->setAttrib('disabled', 'disabled')
                ->setAttrib('class', 'validate[required]');

        //добавить див clear внутри дива loginInput!!!!
        $login->setDecorators(array(
            'ViewHelper',
            //'Description',
            'Errors',
            
            array('HtmlTag', array('tag' => 'div', "class" => "loginInput")),
           // array('HtmlTag', array('tag' => 'div', "class" => "clear", 'placement' => 'append')),
            // array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'clear', 'placement' => 'append')),

            array('Label'),
            //array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'clear', 'placement' => 'append', 'openOnly' => true)),
            
            array(array('row' => 'HtmlTag'), array('tag' => 'div', "class" => 'formRow')),
            
            array(array('endbit' => 'HtmlTag'), array('tag' => 'fieldset', "style" => 'float:left', 'openOnly' => true)),
        ));

        $password = new Zend_Form_Element_Password('password');
        $password->setLabel('Password')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->addValidator('StringLength', true, array(8, 20))
                ->addValidator('Alnum')
                ->addFilter('StringTrim')
                ->addFilter('StripTags')
                ->setAttrib('id', 'pass')
                ->setAttrib('class', 'validate[required]');

        $password->setDecorators(array(
            'ViewHelper',
            //'Description',
            'Errors',
            array('HtmlTag', array('tag' => 'div', "class" => "loginInput")),
            array('Label'),
            array(array('endbit' => 'HtmlTag'), array('tag' => 'div', 'class' => 'clear', 'placement' => 'append')),
            array(array('row' => 'HtmlTag'), array('tag' => 'div', "class" => 'formRow'))
        ));

        $repeat_password = new Zend_Form_Element_Password('repeat_password');
        $repeat_password->setLabel('Repeat password')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->addValidator('Alnum')
                ->addFilter('StringTrim')
                ->addFilter('StripTags')
                ->setAttrib('id', 'repeatpass')
                ->setAttrib('class', 'validate[required]');

        $repeat_password->setDecorators(array(
            'ViewHelper',
            //'Description',
            'Errors',
            array('HtmlTag', array('tag' => 'div', "class" => "loginInput")),
            array('Label'),
            array(array('endbit' => 'HtmlTag'), array('tag' => 'div', 'class' => 'clear', 'placement' => 'append')),
            array(array('row' => 'HtmlTag'), array('tag' => 'div', "class" => 'formRow'))
        ));

        $email = new Zend_Form_Element_Text('email');
        $email->setLabel('Email address')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->addValidator('EmailAddress')
                ->addFilter('StringTrim')
                ->addFilter('StripTags')
                ->setAttrib('id', 'emailValid')
                ->setAttrib('class', 'validate[required,custom[email]]');

        $email->setDecorators(array(
            'ViewHelper',
            //'Description',
            'Errors',
            array('HtmlTag', array('tag' => 'div', "class" => "loginInput")),
            array('Label'),
            array(array('endbit' => 'HtmlTag'), array('tag' => 'div', 'class' => 'clear', 'placement' => 'append')),
            array(array('row' => 'HtmlTag'), array('tag' => 'div', "class" => 'formRow')),
            array(array('row' => 'HtmlTag'), array('tag' => 'fieldset', 'placement' => 'append', 'closeOnly' => true))
        ));

        $phone = new Zend_Form_Element_Text('phone');
        $phone->setLabel('Phone')
                ->addValidator('Digits')
                ->addFilter('StringTrim')
                ->addFilter('StripTags')
                ->setAttrib('id', 'numsValid')
                ->setAttrib('class', 'validate[required,custom[onlyNumberSp]]');

        $phone->setDecorators(array(
            'ViewHelper',
            //'Description',
            'Errors',
            array('HtmlTag', array('tag' => 'div', "class" => "loginInput")),
            array('Label'),
            array(array('endbit' => 'HtmlTag'), array('tag' => 'div', 'class' => 'clear', 'placement' => 'append')),
            array(array('row' => 'HtmlTag'), array('tag' => 'fieldset', "style" => 'float:right', 'openOnly' => true)),
            array(array('endbit' => 'HtmlTag'), array('tag' => 'div', "class" => 'formRow'))
        ));

        $address = new Zend_Form_Element_Text('address');
        $address->setLabel('Address')
                ->addValidator('Digits')
                ->addFilter('StringTrim')
                ->addFilter('StripTags')
                ->setAttrib('id', 'numsValid')
                ->setAttrib('class', 'validate[required,maxSize[50]]');

        $address->setDecorators(array(
            'ViewHelper',
            //'Description',
            'Errors',
            array('HtmlTag', array('tag' => 'div', "class" => "loginInput")),
            array('Label'),
            array(array('endbit' => 'HtmlTag'), array('tag' => 'div', 'class' => 'clear', 'placement' => 'append')),
            array(array('row' => 'HtmlTag'), array('tag' => 'div', "class" => 'formRow'))
        ));

        $company = new Zend_Form_Element_Text('company_name');
        $company->setLabel('Company name')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->addValidator('Alnum', false, array('allowWhiteSpace' => true))
                ->addFilter('StringTrim')
                ->addFilter('StripTags')
                ->setAttrib('id', 'maxValid')
                ->setAttrib('class', 'validate[required,maxSize[50]]');

        $company->setDecorators(array(
            'ViewHelper',
            //'Description',
            'Errors',
            array('HtmlTag', array('tag' => 'div', "class" => "loginInput")),
            array('Label'),
            array(array('endbit' => 'HtmlTag'), array('tag' => 'div', 'class' => 'clear', 'placement' => 'append')),
            array(array('row' => 'HtmlTag'), array('tag' => 'div', "class" => 'formRow'))
        ));

        $site = new Zend_Form_Element_Text('website');
        $site->setLabel('Website')
                ->addFilter('StringTrim')
                ->addFilter('StripTags')
                ->setAttrib('id', 'req')
                ->setAttrib('class', 'validate[required]');

        $site->setDecorators(array(
            'ViewHelper',
            //'Description',
            'Errors',
            array('HtmlTag', array('tag' => 'div', "class" => "loginInput")),
            array('Label'),
            array(array('endbit' => 'HtmlTag'), array('tag' => 'div', 'class' => 'clear', 'placement' => 'append')),
            array(array('row' => 'HtmlTag'), array('tag' => 'div', "class" => 'formRow'))
        ));

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Update')
                ->setAttrib('class', 'button')
                ->setAttrib('class', 'greenB logMeIn');

        $submit->setDecorators(array(
            'ViewHelper',
            //'Description',
            'Errors',
            array('HtmlTag', array('tag' => 'div', "class" => "loginControl", 'openOnly' => true)),
            array(array('endbit' => 'HtmlTag'), array('tag' => 'div', 'class' => 'clear', 'placement' => 'append')),
            array(array('endbit' => 'HtmlTag'), array('tag' => 'div', 'placement' => 'append', 'closeOnly' => true)),
            array(array('row' => 'HtmlTag'), array('tag' => 'fieldset', 'placement' => 'append', 'closeOnly' => true))
        ));

        $this->addElements(array($login, $password, $repeat_password, $email,
            $phone, $address, $company, $site, $submit));
    }

}

